package util;

import java.util.List;

import common.Server;

import model.ShareFileModel;

public class LogServerUtil {

	/**
	 * 根据文件名称,从服务开放文件列表中得到共享文件
	 * 
	 * @param shareFileModels
	 * @param fileName
	 * @return not find return null.
	 */
	public static ShareFileModel getSendFile (List<ShareFileModel> shareFileModels, String fileName) {
		
		for (ShareFileModel shareFileModel : shareFileModels) {
			if (fileName.equals(shareFileModel.getFileName())) {
				return shareFileModel;
			}
		}
		return null;
	}
	
	/**
	 * 如果是允许IP return true,else true false
	 * 
	 * @param address
	 * @return
	 */
	public static boolean isRegisterAddress(String address) {
		
		String adds = Server.rb.getString("register_address");
		if(null == adds || "".equals(adds)){
			return false;
		}
		String []addresses = adds.split(",");
		for(String add : addresses) {
			if( add.equals(address) ) {
				return true;
			}
		}
		return false;
	}
}
